package com.yixin.service.impl;

import com.yixin.entity.Permission;
import com.yixin.mapper.PermissionMapper;
import com.yixin.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public void add(Permission permission) {
        permission.setIsDel(0);
        permission.setCreateTime(LocalDateTime.now());
        permission.setUpdateTime(LocalDateTime.now());
        permissionMapper.add(permission);
    }

    @Override
    public void update(Permission permission) {
        permission.setUpdateTime(LocalDateTime.now());
        permissionMapper.update(permission);
    }

    @Override
    public void deleteById(Integer id) {
        permissionMapper.deleteById(id);
    }

    @Override
    public List<Permission> findAll() {
        return permissionMapper.findAll();
    }
}
